<template>
    <div style="width: 100%">
        <el-input v-if="!isInstanceSearch" :style="inputStyle" :disabled="isDisable" v-model="properties.bindValue"
                  :placeholder="properties.inputPlaceHolder" :clearable="properties.isClearable"
                  :type="properties.isPassword ? 'password' : (properties.isTextArea ? 'textarea' : '')"
                  :autosize="autosizeRes">

        </el-input>
        <el-input v-if="isInstanceSearch" :style="inputStyle" :disabled="isDisable" v-model="properties.searchValue"
                  :placeholder="properties.inputPlaceHolder" :clearable="properties.isClearable"
                  :type="properties.isPassword ? 'password' : (properties.isTextArea ? 'textarea' : '')"
                  :autosize="autosizeRes">

        </el-input>
    </div>
</template>

<script setup name="YwuFormInput">

import {computed, defineProps} from "vue";

let props = defineProps(['isEdit', 'properties', 'isInstanceSearch', "isDisable"]);

let isEdit = computed(() => {return props['isEdit']})
let properties = computed(() => {return props['properties']})
let isInstanceSearch = computed(() => {return props['isInstanceSearch']})
let isDisable = computed(() => {return props['isDisable']})

let inputStyle = computed(() => {
    if (isEdit.value) {
        return "pointer-events: none;"
    } else {
        return "";
    }
})

let autosizeRes = computed(() => {
    if (!properties.value.isTextArea) {
        return false
    }
    if (properties.value.isAutoSize) {
        return true
    }
    return {minRows: parseInt(properties.value.minRow), maxRows: parseInt(properties.value.maxRow)}
})
</script>

<style scoped lang="less">

</style>